﻿
namespace ATA.Windows.Forms
{
	/// <summary>
	/// abstract ChietKhauSanPham typed datagridview
	/// </summary>
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	public abstract class ChietKhauSanPhamDataGridViewBase : System.Windows.Forms.UserControl
	{	
		/// <summary> 
		/// Thrown when the current Entity changed.
		/// </summary>
		public event System.EventHandler<ChietKhauSanPhamDataGridViewEventArgs> CurrentEntityChanged;
		
		#region Fields
				
		/// <summary> 
		/// the current entity.
		/// </summary>
		private Entities.ChietKhauSanPham _currentChietKhauSanPham = null;
		//private Dictionary<string, string> _columnsHeaders = new Dictionary<string, string>();
		
		/// <summary> 
		/// the datagridview instance
		/// </summary>
		protected System.Windows.Forms.DataGridView uxChietKhauSanPhamDataGridView;
		
		/// <summary> 
		/// the errorprovider
		/// </summary>
		protected System.Windows.Forms.ErrorProvider uxChietKhauSanPhamErrorProvider;
		
		/// <summary> 
		/// the bindingsource
		/// </summary>
		protected System.Windows.Forms.BindingSource uxChietKhauSanPhamBindingSource;
		
		
		/// <summary> 
		/// the DGV column associated with the ChietKhauSpid property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxChietKhauSpidDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the NhomSanPhamId property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxNhomSanPhamIdDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the DonViTinhId property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxDonViTinhIdDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the SoLuong property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxSoLuongDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the MucThuong property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxMucThuongDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the LoaiThuong property
		/// </summary>
		protected System.Windows.Forms.DataGridViewCheckBoxColumn uxLoaiThuongDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the ChietKhauId property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxChietKhauIdDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the LastUpdate property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxLastUpdateDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the UpdateBy property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxUpdateByDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the HinhThucThuong property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxHinhThucThuongDataGridViewColumn;
		
		#endregion
					
		#region Combo list
		
				
		private Entities.TList<Entities.NhomSanPham> _NhomSanPhamIdList;
		
		/// <summary> 
		/// The list of selectable NhomSanPham
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.NhomSanPham> NhomSanPhamIdList
		{
			get {return this._NhomSanPhamIdList;}
			set 
			{
				this._NhomSanPhamIdList = value;
				this.uxNhomSanPhamIdDataGridViewColumn.DataSource = null;
				this.uxNhomSanPhamIdDataGridViewColumn.DataSource = this._NhomSanPhamIdList;
			}
		}
		
		private bool _allowNewItemInNhomSanPhamIdList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of NhomSanPham
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInNhomSanPhamIdList
		{
			get { return _allowNewItemInNhomSanPhamIdList;}
			set
			{
				this._allowNewItemInNhomSanPhamIdList = value;
				this.uxNhomSanPhamIdDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
				
		private Entities.TList<Entities.ChietKhau> _ChietKhauIdList;
		
		/// <summary> 
		/// The list of selectable ChietKhau
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.ChietKhau> ChietKhauIdList
		{
			get {return this._ChietKhauIdList;}
			set 
			{
				this._ChietKhauIdList = value;
				this.uxChietKhauIdDataGridViewColumn.DataSource = null;
				this.uxChietKhauIdDataGridViewColumn.DataSource = this._ChietKhauIdList;
			}
		}
		
		private bool _allowNewItemInChietKhauIdList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of ChietKhau
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInChietKhauIdList
		{
			get { return _allowNewItemInChietKhauIdList;}
			set
			{
				this._allowNewItemInChietKhauIdList = value;
				this.uxChietKhauIdDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
				
		private Entities.TList<Entities.DonViTinh> _DonViTinhIdList;
		
		/// <summary> 
		/// The list of selectable DonViTinh
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.DonViTinh> DonViTinhIdList
		{
			get {return this._DonViTinhIdList;}
			set 
			{
				this._DonViTinhIdList = value;
				this.uxDonViTinhIdDataGridViewColumn.DataSource = null;
				this.uxDonViTinhIdDataGridViewColumn.DataSource = this._DonViTinhIdList;
			}
		}
		
		private bool _allowNewItemInDonViTinhIdList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of DonViTinh
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInDonViTinhIdList
		{
			get { return _allowNewItemInDonViTinhIdList;}
			set
			{
				this._allowNewItemInDonViTinhIdList = value;
				this.uxDonViTinhIdDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
		#endregion
		
		#region Main Datasource
		
		private Entities.TList<Entities.ChietKhauSanPham> _ChietKhauSanPhamList;
				
		/// <summary> 
		/// The list of ChietKhauSanPham to be displayed in the DGV.
		/// </summary>
		[System.ComponentModel.Category("Data")]
		public Entities.TList<Entities.ChietKhauSanPham> ChietKhauSanPhamList
		{
			get {return this._ChietKhauSanPhamList;}
			set
			{
				this._ChietKhauSanPhamList = value;
				this.uxChietKhauSanPhamBindingSource.DataSource = null;
				this.uxChietKhauSanPhamBindingSource.DataSource = value;
				this.uxChietKhauSanPhamDataGridView.DataSource = null;
				this.uxChietKhauSanPhamDataGridView.DataSource = this.uxChietKhauSanPhamBindingSource;				
				//this.uxChietKhauSanPhamBindingSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(uxChietKhauSanPhamBindingSource_ListChanged);
				this.uxChietKhauSanPhamBindingSource.CurrentItemChanged += new System.EventHandler(OnChietKhauSanPhamBindingSourceCurrentItemChanged);
			}
		}
		
		private void OnChietKhauSanPhamBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
		{
			_currentChietKhauSanPham = uxChietKhauSanPhamBindingSource.Current as Entities.ChietKhauSanPham;
			
			if (_currentChietKhauSanPham != null)
			{
				_currentChietKhauSanPham.Validate();
			}
			//_ChietKhauSanPham.Validate();
			OnCurrentEntityChanged();
		}

		//void uxChietKhauSanPhamBindingSource_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
		//{
			//throw new Exception("The method or operation is not implemented.");
		//}		
		
		#endregion
		
		/// <summary>
		/// Gets the currently selected <c cref="Entities.ChietKhauSanPham"/> instance.
		/// </summary>
		public Entities.ChietKhauSanPham SelectedChietKhauSanPham
		{
			get {return this._currentChietKhauSanPham;}
		}
		
		#region other properties
		
		/// <summary>
		/// Gets or sets a value indicating whether you have provided your own data-management operations for the DataGridView control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool VirtualMode
		{
			get {return this.uxChietKhauSanPhamDataGridView.VirtualMode;}
			set
			{
				this.uxChietKhauSanPhamDataGridView.VirtualMode = value;
			}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the option to add rows is displayed to the user.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToAddRows
		{
			get {return this.uxChietKhauSanPhamDataGridView.AllowUserToAddRows;}
			set {this.uxChietKhauSanPhamDataGridView.AllowUserToAddRows = value;}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the user is allowed to delete rows from the DataGridView.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToDeleteRows
		{
			get {return this.uxChietKhauSanPhamDataGridView.AllowUserToDeleteRows;}
			set {this.uxChietKhauSanPhamDataGridView.AllowUserToDeleteRows = value;}
		}
		
		/// <summary>
		/// Gets the <c cref="DataGridView"/> instance.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public System.Windows.Forms.DataGridView DataGridView
		{
			get {return this.uxChietKhauSanPhamDataGridView;}
		}
		
		/// <summary>
		/// Gets a collection that contains all the columns in the control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]		
		[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)]
		//[System.ComponentModel.EditorAttribute("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design", typeof(System.Drawing.Design.UITypeEditor))] 
		public System.Windows.Forms.DataGridViewColumnCollection Columns
		{
			get { return this.uxChietKhauSanPhamDataGridView.Columns; }
		}
		
		#endregion
		
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;
	
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}
	
		#region Constructor
	
		/// <summary>
		/// Initializes a new instance of the <see cref="ChietKhauSanPhamDataGridViewBase"/> class.
		/// </summary>
		public ChietKhauSanPhamDataGridViewBase()
		{			
			this.components = new System.ComponentModel.Container();			
			
			this.uxChietKhauSanPhamDataGridView = new System.Windows.Forms.DataGridView();
			this.uxChietKhauSanPhamBindingSource = new System.Windows.Forms.BindingSource(this.components);
			this.uxChietKhauSanPhamErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxChietKhauSpidDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxNhomSanPhamIdDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxDonViTinhIdDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxSoLuongDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxMucThuongDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxLoaiThuongDataGridViewColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
			this.uxChietKhauIdDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxLastUpdateDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxUpdateByDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxHinhThucThuongDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			//this.uxNhomSanPhamIdBindingSource = new NhomSanPhamBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxNhomSanPhamIdBindingSource)).BeginInit();
			//this.uxChietKhauIdBindingSource = new ChietKhauBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxChietKhauIdBindingSource)).BeginInit();
			//this.uxDonViTinhIdBindingSource = new DonViTinhBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxDonViTinhIdBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauSanPhamDataGridView)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauSanPhamBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauSanPhamErrorProvider)).BeginInit();
			this.SuspendLayout();
						
			// 
			// uxChietKhauSanPhamErrorProvider
			// 
			this.uxChietKhauSanPhamErrorProvider.ContainerControl = this;
			this.uxChietKhauSanPhamErrorProvider.DataSource = this.uxChietKhauSanPhamBindingSource;						
			// 
			// uxChietKhauSanPhamDataGridView
			// 
			this.uxChietKhauSanPhamDataGridView.AutoGenerateColumns = false;
			this.uxChietKhauSanPhamDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.uxChietKhauSanPhamDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
		this.uxChietKhauSpidDataGridViewColumn,
		this.uxNhomSanPhamIdDataGridViewColumn,
		this.uxDonViTinhIdDataGridViewColumn,
		this.uxSoLuongDataGridViewColumn,
		this.uxMucThuongDataGridViewColumn,
		this.uxLoaiThuongDataGridViewColumn,
		this.uxChietKhauIdDataGridViewColumn,
		this.uxLastUpdateDataGridViewColumn,
		this.uxUpdateByDataGridViewColumn,
		this.uxHinhThucThuongDataGridViewColumn			});
			this.uxChietKhauSanPhamDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
			this.uxChietKhauSanPhamDataGridView.Location = new System.Drawing.Point(0, 0);
			this.uxChietKhauSanPhamDataGridView.Name = "uxChietKhauSanPhamDataGridView";
			this.uxChietKhauSanPhamDataGridView.Size = new System.Drawing.Size(470, 300);
			this.uxChietKhauSanPhamDataGridView.TabIndex = 0;	
			this.uxChietKhauSanPhamDataGridView.BackgroundColor = System.Drawing.Color.WhiteSmoke;
			this.uxChietKhauSanPhamDataGridView.EnableHeadersVisualStyles = false;
			this.uxChietKhauSanPhamDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.OnChietKhauSanPhamDataGridViewDataError);
			this.uxChietKhauSanPhamDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnChietKhauSanPhamDataGridViewCellValueNeeded);
			this.uxChietKhauSanPhamDataGridView.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnChietKhauSanPhamDataGridViewCellValuePushed);
			
			//
			// uxChietKhauSpidDataGridViewColumn
			//
			this.uxChietKhauSpidDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxChietKhauSpidDataGridViewColumn.DataPropertyName = "ChietKhauSpid";
			this.uxChietKhauSpidDataGridViewColumn.HeaderText = "ChietKhauSpid";
			this.uxChietKhauSpidDataGridViewColumn.Name = "uxChietKhauSpidDataGridViewColumn";
			this.uxChietKhauSpidDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxChietKhauSpidDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxChietKhauSpidDataGridViewColumn.ReadOnly = false;		
			//
			// uxNhomSanPhamIdDataGridViewColumn
			//
			this.uxNhomSanPhamIdDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNhomSanPhamIdDataGridViewColumn.DataPropertyName = "NhomSanPhamId";
			this.uxNhomSanPhamIdDataGridViewColumn.HeaderText = "NhomSanPhamId";
			this.uxNhomSanPhamIdDataGridViewColumn.Name = "uxNhomSanPhamIdDataGridViewColumn";
			this.uxNhomSanPhamIdDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNhomSanPhamIdDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNhomSanPhamIdDataGridViewColumn.ReadOnly = false;		
			//
			// uxDonViTinhIdDataGridViewColumn
			//
			this.uxDonViTinhIdDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxDonViTinhIdDataGridViewColumn.DataPropertyName = "DonViTinhId";
			this.uxDonViTinhIdDataGridViewColumn.HeaderText = "DonViTinhId";
			this.uxDonViTinhIdDataGridViewColumn.Name = "uxDonViTinhIdDataGridViewColumn";
			this.uxDonViTinhIdDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxDonViTinhIdDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxDonViTinhIdDataGridViewColumn.ReadOnly = false;		
			//
			// uxSoLuongDataGridViewColumn
			//
			this.uxSoLuongDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxSoLuongDataGridViewColumn.DataPropertyName = "SoLuong";
			this.uxSoLuongDataGridViewColumn.HeaderText = "SoLuong";
			this.uxSoLuongDataGridViewColumn.Name = "uxSoLuongDataGridViewColumn";
			this.uxSoLuongDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxSoLuongDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxSoLuongDataGridViewColumn.ReadOnly = false;		
			//
			// uxMucThuongDataGridViewColumn
			//
			this.uxMucThuongDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxMucThuongDataGridViewColumn.DataPropertyName = "MucThuong";
			this.uxMucThuongDataGridViewColumn.HeaderText = "MucThuong";
			this.uxMucThuongDataGridViewColumn.Name = "uxMucThuongDataGridViewColumn";
			this.uxMucThuongDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxMucThuongDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxMucThuongDataGridViewColumn.ReadOnly = false;		
			//
			// uxLoaiThuongDataGridViewColumn
			//
			this.uxLoaiThuongDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxLoaiThuongDataGridViewColumn.DataPropertyName = "LoaiThuong";
			this.uxLoaiThuongDataGridViewColumn.HeaderText = "LoaiThuong";
			this.uxLoaiThuongDataGridViewColumn.Name = "uxLoaiThuongDataGridViewColumn";
			this.uxLoaiThuongDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxLoaiThuongDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxLoaiThuongDataGridViewColumn.ReadOnly = false;		
			//
			// uxChietKhauIdDataGridViewColumn
			//
			this.uxChietKhauIdDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxChietKhauIdDataGridViewColumn.DataPropertyName = "ChietKhauId";
			this.uxChietKhauIdDataGridViewColumn.HeaderText = "ChietKhauId";
			this.uxChietKhauIdDataGridViewColumn.Name = "uxChietKhauIdDataGridViewColumn";
			this.uxChietKhauIdDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxChietKhauIdDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxChietKhauIdDataGridViewColumn.ReadOnly = false;		
			//
			// uxLastUpdateDataGridViewColumn
			//
			this.uxLastUpdateDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxLastUpdateDataGridViewColumn.DataPropertyName = "LastUpdate";
			this.uxLastUpdateDataGridViewColumn.HeaderText = "LastUpdate";
			this.uxLastUpdateDataGridViewColumn.Name = "uxLastUpdateDataGridViewColumn";
			this.uxLastUpdateDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxLastUpdateDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxLastUpdateDataGridViewColumn.ReadOnly = false;		
			//
			// uxUpdateByDataGridViewColumn
			//
			this.uxUpdateByDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxUpdateByDataGridViewColumn.DataPropertyName = "UpdateBy";
			this.uxUpdateByDataGridViewColumn.HeaderText = "UpdateBy";
			this.uxUpdateByDataGridViewColumn.Name = "uxUpdateByDataGridViewColumn";
			this.uxUpdateByDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxUpdateByDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxUpdateByDataGridViewColumn.ReadOnly = false;		
			//
			// uxHinhThucThuongDataGridViewColumn
			//
			this.uxHinhThucThuongDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxHinhThucThuongDataGridViewColumn.DataPropertyName = "HinhThucThuong";
			this.uxHinhThucThuongDataGridViewColumn.HeaderText = "HinhThucThuong";
			this.uxHinhThucThuongDataGridViewColumn.Name = "uxHinhThucThuongDataGridViewColumn";
			this.uxHinhThucThuongDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxHinhThucThuongDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxHinhThucThuongDataGridViewColumn.ReadOnly = false;		
			//
			// uxNhomSanPhamIdDataGridViewColumn
			//				
			this.uxNhomSanPhamIdDataGridViewColumn.DisplayMember = "SanPhamId";	
			this.uxNhomSanPhamIdDataGridViewColumn.ValueMember = "NhomSanPhamId";	
			this.uxNhomSanPhamIdDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxNhomSanPhamIdDataGridViewColumn.DataSource = uxNhomSanPhamIdBindingSource;				
				
			//
			// uxChietKhauIdDataGridViewColumn
			//				
			this.uxChietKhauIdDataGridViewColumn.DisplayMember = "StartDate";	
			this.uxChietKhauIdDataGridViewColumn.ValueMember = "ChietKhauId";	
			this.uxChietKhauIdDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxChietKhauIdDataGridViewColumn.DataSource = uxChietKhauIdBindingSource;				
				
			//
			// uxDonViTinhIdDataGridViewColumn
			//				
			this.uxDonViTinhIdDataGridViewColumn.DisplayMember = "TenDonViTinh";	
			this.uxDonViTinhIdDataGridViewColumn.ValueMember = "DonViTinhId";	
			this.uxDonViTinhIdDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxDonViTinhIdDataGridViewColumn.DataSource = uxDonViTinhIdBindingSource;				
				
			
			// this
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.Controls.Add(this.uxChietKhauSanPhamDataGridView);
			this.Name = "ChietKhauSanPhamDataGridView";
			this.Size = new System.Drawing.Size(470, 300);
			//((System.ComponentModel.ISupportInitialize)(this.uxNhomSanPhamIdBindingSource)).EndInit();
			//((System.ComponentModel.ISupportInitialize)(this.uxChietKhauIdBindingSource)).EndInit();
			//((System.ComponentModel.ISupportInitialize)(this.uxDonViTinhIdBindingSource)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauSanPhamErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauSanPhamDataGridView)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxChietKhauSanPhamBindingSource)).EndInit();
			this.ResumeLayout(false);
		}
		#endregion
				
		#region events
		
		/// <summary>
		/// Raised the CurrentEntityChanged event.
		/// </summary>
		protected void OnCurrentEntityChanged()
		{
			if (CurrentEntityChanged != null)
			{
				ChietKhauSanPhamDataGridViewEventArgs args = new ChietKhauSanPhamDataGridViewEventArgs();
				args.ChietKhauSanPham = _currentChietKhauSanPham;
				CurrentEntityChanged(this, args); 
			}
		}
		
		#endregion
		
		/// <summary>
		/// Strongly typed event 
		/// </summary>
		public class ChietKhauSanPhamDataGridViewEventArgs : System.EventArgs
		{
			private Entities.ChietKhauSanPham	_ChietKhauSanPham;
	
			/// <summary>
			/// the  Entities.ChietKhauSanPham instance.
			/// </summary>
			public Entities.ChietKhauSanPham ChietKhauSanPham
			{
				get { return _ChietKhauSanPham; }
				set { _ChietKhauSanPham = value; }
			}	
		}
		
		/// <summary>
		/// Handles the DataError event of the uxChietKhauSanPhamDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewDataErrorEventArgs"/> instance containing the event data.</param>
		protected void OnChietKhauSanPhamDataGridViewDataError(object sender, System.Windows.Forms.DataGridViewDataErrorEventArgs e)
		{
			System.Diagnostics.Debug.WriteLine(string.Format( "{0}, {1}", e.ColumnIndex, e.RowIndex));
		}
		
		/// <summary>
		/// Handles the CellValueNeeded event of the uxChietKhauSanPhamDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnChietKhauSanPhamDataGridViewCellValueNeeded(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxChietKhauSanPhamDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxChietKhauSpidDataGridViewColumn":
						e.Value = ChietKhauSanPhamList[e.RowIndex].ChietKhauSpid;
						break;
					case "uxNhomSanPhamIdDataGridViewColumn":
						e.Value = ChietKhauSanPhamList[e.RowIndex].NhomSanPhamId;
						break;
					case "uxDonViTinhIdDataGridViewColumn":
						e.Value = ChietKhauSanPhamList[e.RowIndex].DonViTinhId;
						break;
					case "uxSoLuongDataGridViewColumn":
						e.Value = ChietKhauSanPhamList[e.RowIndex].SoLuong;
						break;
					case "uxMucThuongDataGridViewColumn":
						e.Value = ChietKhauSanPhamList[e.RowIndex].MucThuong;
						break;
					case "uxLoaiThuongDataGridViewColumn":
						e.Value = ChietKhauSanPhamList[e.RowIndex].LoaiThuong;
						break;
					case "uxChietKhauIdDataGridViewColumn":
						e.Value = ChietKhauSanPhamList[e.RowIndex].ChietKhauId;
						break;
					case "uxLastUpdateDataGridViewColumn":
						e.Value = ChietKhauSanPhamList[e.RowIndex].LastUpdate;
						break;
					case "uxUpdateByDataGridViewColumn":
						e.Value = ChietKhauSanPhamList[e.RowIndex].UpdateBy;
						break;
					case "uxHinhThucThuongDataGridViewColumn":
						e.Value = ChietKhauSanPhamList[e.RowIndex].HinhThucThuong;
						break;
				default:
				break;
			}
		}
		
		/// <summary>
		/// Handles the CellValuePushed event of the uxChietKhauSanPhamDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnChietKhauSanPhamDataGridViewCellValuePushed(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxChietKhauSanPhamDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxChietKhauSpidDataGridViewColumn":
						ChietKhauSanPhamList[e.RowIndex].ChietKhauSpid = (System.Guid)e.Value;
						break;
					case "uxNhomSanPhamIdDataGridViewColumn":
						ChietKhauSanPhamList[e.RowIndex].NhomSanPhamId = (System.Guid)e.Value;
						break;
					case "uxDonViTinhIdDataGridViewColumn":
						ChietKhauSanPhamList[e.RowIndex].DonViTinhId = (System.Byte)e.Value;
						break;
					case "uxSoLuongDataGridViewColumn":
						ChietKhauSanPhamList[e.RowIndex].SoLuong = (System.Byte)e.Value;
						break;
					case "uxMucThuongDataGridViewColumn":
						ChietKhauSanPhamList[e.RowIndex].MucThuong = (System.Double)e.Value;
						break;
					case "uxLoaiThuongDataGridViewColumn":
						ChietKhauSanPhamList[e.RowIndex].LoaiThuong = (System.Boolean)e.Value;
						break;
					case "uxChietKhauIdDataGridViewColumn":
						ChietKhauSanPhamList[e.RowIndex].ChietKhauId = (System.Guid)e.Value;
						break;
					case "uxLastUpdateDataGridViewColumn":
						ChietKhauSanPhamList[e.RowIndex].LastUpdate = (System.DateTime)e.Value;
						break;
					case "uxUpdateByDataGridViewColumn":
						ChietKhauSanPhamList[e.RowIndex].UpdateBy = (System.Int32)e.Value;
						break;
					case "uxHinhThucThuongDataGridViewColumn":
						ChietKhauSanPhamList[e.RowIndex].HinhThucThuong = (System.String)e.Value;
						break;
				default:
				break;
			}
		}
	}
}
